package hku.cs.lunuo.rank.model.impl;

import hku.cs.lunuo.rank.StatisticProperty;

import org.jdom.Element;

public class EsStatisticUnit implements Comparable{

	public String klassName;
	public String methodName;
	public String es;
	public StatisticProperty sp;
	
	
	public EsStatisticUnit(String klassName, String methodName, String es,
			StatisticProperty sp) {
		super();
		this.klassName = klassName;
		this.methodName = methodName;
		this.es = es;
		this.sp = sp;
	}


	@Override
	public int compareTo(Object o) {
		EsStatisticUnit es = (EsStatisticUnit)o;
		int a = sp.label.compareTo(es.sp.label);
		if(a!=0)
			return a;
		else {
			int b = sp.tfs.getFlsTimes()-es.sp.tfs.getFlsTimes();
			if(b!=0)
				return b;
			else {
				int c = klassName.compareTo(es.klassName);
				if(c!=0)
					return c;
				else
					return methodName.compareTo(es.methodName);
			}
		}
	}


	public void toXML(Element xml) {
		xml.setAttribute("class", klassName);
		xml.setAttribute("method", methodName);
		xml.setAttribute("es", es);
		sp.toXML(xml);		
	}
}
